package com.woniu.zsd.recycle.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniu.zsd.common.util.Result;
import com.woniu.zsd.recycle.dto.SelectEvaluateByUserIdDto;
import com.woniu.zsd.recycle.form.UserEvaluateForm;
import com.woniu.zsd.recycle.param.UserEvaluateParam;
import com.woniu.zsd.recycle.service.EvaluateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 彭于晏
 * @since 2025年02月18日
 */
@RestController
@RequestMapping("/evaluate")
@Api(tags = "评价管理")
public class EvaluateController {
    @Resource
    private EvaluateService evaluateService;
    @PostMapping("/userEvaluate")
    @ApiOperation(value = "用户评价订单")
    public Result userEvaluate(@RequestBody UserEvaluateForm form)throws Exception{
        evaluateService.userEvaluate(BeanUtil.toBean(form, UserEvaluateParam.class));
        return Result.success("用户评价订单成功",null);
    }
    @PostMapping("/siteReply")
    @ApiOperation(value = "站点回复")
    public Result siteReply(String orderNum,String stationReply)throws Exception{
        evaluateService.siteReply(orderNum,stationReply);
        return Result.success("站点回复成功",null);
    }
    @PostMapping("/selectEvaluateByUserId")
    @ApiOperation(value = "根据用户id查询评价信息")
    public Result selectEvaluateByUserId(Integer userId)throws Exception{
        List<SelectEvaluateByUserIdDto> dtos = evaluateService.selectEvaluateByUserId(userId);
        return Result.success("查询用户评价信息成功",dtos);
    }
    @PostMapping("/cancelEvaluate")
    @ApiOperation(value = "用户撤销评价")
    public Result cancelEvaluate(String orderNum,Integer userId)throws Exception{
        return Result.success("用户撤销评价成功",null);
    }
}

